
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/build/bin")
set(LIBRARY_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/build/lib")


set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

#条件编译
if(CMAKE_HOST_UNIX)

elseif (CMAKE_HOST_WIN32)
    
    add_compile_definitions(_CRT_SECURE_NO_WARNINGS) # 禁止 strcat 等函数报 strcat_s 警告


    # 检测当前使用的编译器
    if(CMAKE_CXX_COMPILER_ID STREQUAL "MinGW")
        message(STATUS "Using MinGW compiler")
        link_libraries(ws2_32 mswsock advapi32 user32)

    elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
        message(STATUS "Using MSVC compiler")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /source-charset:utf-8 /execution-charset:utf-8") # 设置编译选项，使 UTF8 格式的源文件

        add_definitions(-D_CRT_SECURE_NO_WARNINGS)
        add_compile_options(/wd4251)
        add_definitions(-D_WIN32_WINNT=0x0A00)

    elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
        message(STATUS "Using Clang compiler")

    else()
        message("Unknown compiler or generator:" ${CMAKE_CXX_COMPILER_ID})
        
    endif()
endif()
